package com.open4cn.simulator.parser.xrite.x7000;

import com.open4cn.simulator.answer.LogInstructionAction;
import com.open4cn.simulator.answer.xrite.ChangeSpecularGlossAction;
import com.open4cn.simulator.answer.xrite.ChangeSpecularGlossAnswer;
import com.open4cn.simulator.core.answer.AbstractAnswer;
import com.open4cn.simulator.core.answer.AnswerResponse;
import com.open4cn.simulator.core.ext.XriteStatus;
import com.open4cn.simulator.core.parser.IInstructionParser;
import com.open4cn.simulator.core.parser.InstructionParserChain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.List;

/**
 * @author yinxiaopeng
 * @version 1.0.0
 * @company 致景科技
 * @department 飞梭BU/研发
 * @description 修改设备镜面光泽为不包含
 * @Email yinxiaopeng@zj.tech
 * @date 2022-05-13 00:57
 */
public class E1 implements IInstructionParser {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    private static final String COMMAND = "E1";

    private ChangeSpecularGlossAnswer answer = new ChangeSpecularGlossAnswer();

    private XriteStatus xriteStatus;


    public E1(XriteStatus xriteStatus) {
        this.xriteStatus = xriteStatus;
        init();
    }


    private void init() {
        answer.setActions(Arrays.asList(
                new LogInstructionAction(),
                new ChangeSpecularGlossAction()
        ));
    }

    @Override
    public Object parse(Object msg, InstructionParserChain chain) {
        String instruction = (String) msg;
        if (!COMMAND.equals(msg)) {
            return chain.filter(msg);
        }
        AnswerResponse response = this.answer.answer(xriteStatus, XriteStatus.SpecularGlossEnum.SCE, instruction);
        return response.getData();
    }

    @Override
    public List<AbstractAnswer> getAnswers() {
        return Arrays.asList(answer);
    }
}
